<?php
class PNSpaMenuArray extends PNObjectArray {
  function PNSpaMenuArray($init=null, $where='')
  {
    $this->PNObject();

    $this->_objType       = 'spaservice_spamenu';
    $this->_objField      = 'id';
    $this->_objPath       = 'form';
    
    $this->_objJoin[]     = array ( 'join_table'  =>  'spaservice_spacategory',
                            'join_field'          =>  array('id','title','titleTranslate'),
                            'object_field_name'   =>  array('category_id','category_title','category_titleTranslate'),
                            'compare_field_table' =>  'spaCategory_id',
                            'compare_field_join'  =>  'id');
                            
    $this->_init($init, $where);
  }
  
  function selectExtendResult(){
  
    foreach($this->_objData AS $key=>$value){      
      $pntables = pnDBGetTables();
      $tableSpaMenuTime  = $pntables['spaservice_spamenutime'];
      $columnSpaMenuTime = $pntables['spaservice_spamenutime_column'];
    
      $sql = "SELECT
                $tableSpaMenuTime.$columnSpaMenuTime[id],
                $tableSpaMenuTime.$columnSpaMenuTime[price],
                $tableSpaMenuTime.$columnSpaMenuTime[timeMins]
              FROM
                $tableSpaMenuTime
              WHERE 
                $tableSpaMenuTime.$columnSpaMenuTime[spaMenu_id] = $value[id]
              ORDER BY 
                $tableSpaMenuTime.$columnSpaMenuTime[id] ASC ";
      
      $column = array("id", "price","timeMins");
      $sqlResult = DBUtil::executeSQL($sql);
      $result['spaMenuTime'][$value[id]] = DBUtil::marshallObjects ($sqlResult, $column);
    }
    
    return $result;
    
  }

}